$(document).ready(function() {
//	Retrieve.ClickRetrieveBtn();
var Main = {
	data() {
		return {
			mobile: '15122931575',
			vcode: ''
		}
	},
    methods: {
    	getCode: function() {
    		var self = this
    		$.ajax({
				type: "post",
				url: "http://www.ibabypet.com.cn/public/index.php/api/account/sms/",
				async: true,
				data: {
					mobile: self.mobile
				},
				success: function(res){
					res = JSON.parse(res);
					if(res.code==200){
						console.log('res', res)
					}else{
						console.log('res', res)
					}
				}
			});
    	},
    	getPassword: function(){
    		var self = this
    		$.ajax({
				type: "post",
				url: "http://www.ibabypet.com.cn/public/index.php/api/account/get_pcpwd/",
				async: true,
				data: {
					username: self.mobile,
					vcode: self.vcode
				},
				success: function(res){
					res = JSON.parse(res);
					if(res.code==200){
						console.log('res', res)
					}else{
						console.log('res', res)
					}
				}
			});
    	}
    }
  }
var Ctor = Vue.extend(Main)
new Ctor().$mount('.register_content')
});

var Retrieve = {
	//获取验证码
	url_api2: 'http://www.ibabypet.com.cn/public/index.php/api/account/sms/',
	//找回密码  username(登录账号即手机号),vcode(手机验证码)
	url_api: 'http://www.ibabypet.com.cn/public/index.php/api/account/get_pcpwd/',
	ClickRetrieveBtn: function() {
		$('.verify_btn').on('click', function() {
			var that = this;
			var mobile_num = $.trim($('#user').val());

			function checkPhone(phone) {
				if(!(/^1[34578]\d{9}$/.test(phone))) {
					alert("手机号码有误，请重填");
					return false;
				}else{
					return 1;
				}
			};
			var boolen = checkPhone(mobile_num);
			if(!boolen){
				return false;
				alert('输入手机号有误！')
			};
			$.ajax({
				type: "post",
				url: that.url_api2,
				async: true,
				data: {
					mobile: mobile_num
				},
				success: function(res){
					res = JSON.parse(res);
					if(res.code==200){
						alert('找回成功！')
					}else{
						alert(res)
					}
				}
			});
		});
		
		
		$('.retrieve_btn').on('click', function() {
			var that = this;
			var mobile_num = $.trim($('#user').val());
			var verifycode = $.trim($('#verifycode').val());
			
			$.ajax({
				type: "post",
				url: that.url_api,
				async: true,
				data: {
					username: mobile_num,
					vcode: verifycode
				},
				success: function(res){
					res = JSON.parse(res);
					if(res.code==200){
						alert('找回成功！')
					}else{
						alert(res)
					}
				}
			});
		})
	}
}